﻿/// <reference path="worm.js" />
/// <reference path="controller.js" />
/// <reference path="inputManager.js" />
/// <reference path="camera.js" />
/// <reference path="scene.js" />


var app = {

    /// Contains the data of the application
    data: {
        worms: new Array(),
        controllers: new Array(),
        camera: new Camera(),
        scene: new Scene("world1")
    },

    /// Contains the app context
    context: {
        container: null,
        container2d: null,
        //activeController: null,
        activeWorm: null,
        rootUrl: window.top.location.href.substr(0, window.top.location.href.lastIndexOf("/") + 1),
        isInDebugMode: true,
        frameRate: 30,
        gravity: -10,
        
        // Initialization states
        sceneIsLoaded : false
    },

    /// Contains input information
    input: {
        inputManager: new InputManager(),
        key: {
            isRightKeyPressed: false,
            isLeftKeyPressed: false,
            isJumpKeyPressed: false,
            isCameraTrackKeyPressed: false,
            isCameraRightKeyPressed: false,
            isCameraLeftKeyPressed: false,
            isCameraUpKeyPressed: false,
            isCameraDownKeyPressed: false
        }
    },

    UI : {
        ToScreenX : function(x) { return x - app.data.camera.x; },
        ToScreenY : function(y) { return app.data.camera.y - y; },

        ToWorldX : function(x) { return app.data.camera.x - x; },
        ToWorldY : function(y) { return y - app.data.camera.y; }
    },
    
    action : {
        Step : null,
        StartLoopIfReady : null
    }
};